package homework.day03;

import java.io.*;

public class Test3 {
    public static void main(String[] args) throws IOException {
        //获取io目录下的所有子项
        File dir = new File("./src/main/java/io");
        //将dir里文件名".java"结尾的文件转化为文件数组
        File[] subs = dir.listFiles(f->f.getName().endsWith(".java"));
        //声明String变量
        String line;
        //遍历subs数组
        for(int i=0;i<subs.length;i++){
            //获取下标为i的数组元素
            File sub = subs[i];
            //字符流连接到sub，套娃
            BufferedReader br = new BufferedReader(
                    new InputStreamReader(
                            new FileInputStream(sub)
                    )
            );
            //每次读取一行字符直到结束
            while((line = br.readLine())!=null){
                //在控制台输出读取到的字符
                System.out.println(line);
            }
        }
    }
}
